#ifndef game_screen_h
#define game_screen_h

#include <OpenGL/gl.h>
#include <Glut/glut.h>

#include "core.h"

// Some transitions between screens.
enum TransitionType {
    TRANSITION_NONE,
    TRANSITION_FADE_OUT,
    TRANSITION_LEFT,
    TRANSITION_RIGHT,
    TRANSITION_UP,
    TRANSITION_DOWN,
    TRANSITION_LIMIT
};

class Screen;

struct ScreenState {
    Screen *screen;
    double t;
    TransitionType tt;
    bool current;
};

// Something that can manage transitions between screens.
// Create a Screen object for each different view in the game,
// and use the TransitionToScreen to swap between them.
class ScreenManager {
public:
    ScreenManager(Screen *start_screen);
    ~ScreenManager();
    void TransitionToScreen(Screen *screen, TransitionType t);
    // Call this to draw the screens.
    void Draw();
    // Call this to tick both screens. dt is the length of the previous
    // frame in seconds.
    void Tick(double dt);
private:
    ScreenState current;
    ScreenState previous;
};

class Screen {
public:
    Screen() {}
    virtual ~Screen() {}
    // Called by ScreenManager to draw the screen.
    virtual void Draw() {}
    // Called by ScreenManager. 'active' is set if the screen is the
    // current one (rather than being transitioned off).
    virtual void Tick(double dt, bool active) {}
    virtual void Init() {}
};

#endif
